#include <iostream>

using namespace std;

class Solution
{
public:
    int search(int A[], int n, int target)
	{
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        
		int left = 0, right = n-1;
		while(left<=right)
		{
			int mid = left + (right-left)/2;
			if(A[mid] == target)
				return mid;
			else if(A[left]<=A[right])
			{
				if(A[mid]<target)
					left = mid+1;
				else
					right = mid-1;
			}
			else
			{
				if(A[left]<=A[mid])
				{
					if(target<A[mid] && target>=A[left])
						right = mid-1;
					else
						left = mid+1;
				}
				else
				{
					if(target>A[mid] && target<=A[right])
						left = mid+1;
					else
						right = mid-1;
				}
			}
		}

		return -1;
    }
};

int main()
{
	int n,k;
	Solution s;
	while(cin>>n)
	{
		if(n<=0)
			break;
		cin>>k;
		int* A = new int[n];
		for(int i=0;i<n;i++)
			cin>>A[i];

		int idx = s.search(A,n,k);
		cout<<idx<<endl;		
	}
}

